/**
 * 
 */
package examples.client;

import java.util.Properties;

import javax.ejb.NoSuchEJBException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import examples.session.stateful.Cart;
import examples.session.stateless.Pricer;

/**
 * @author 814168
 * 
 */
public class PriceClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Properties jndiProps = new Properties();
			jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
					"org.jnp.interfaces.NamingContextFactory");
			jndiProps.setProperty(Context.URL_PKG_PREFIXES,
					"org.jboss.naming:org.jnp.interface");
			jndiProps.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");

			InitialContext ic = new InitialContext(jndiProps);

			Pricer pricer = (Pricer) ic.lookup("PricerBean/remote");

			System.out.println("Tax (using lookup) on: "
							+ args[0]
							+ " for State: "
							+ args[1]
							+ " is: "
							+ pricer.getTaxLookup(Double.parseDouble(args[0]),
									args[1]));
			System.out.println("Tax (using injection) on: "
					+ args[0]
					+ " for State: "
					+ args[1]
					+ " is: "
					+ pricer.getTaxInjection(Double.parseDouble(args[0]),
							args[1]));
		} catch (NamingException e) {
			e.printStackTrace();
		}

	}

}
